import { request } from '@umijs/max';
import { PageResponse } from './index';

export interface TvSeriesInfo {
    id: number|undefined;
    title: string;
    genre: string;
    releaseDate: string;
    numberOfEpisodes: number;
    director: string;
    playRole: string;
    type: string;
    description: string;
    poster: number;
    famousPersonId: number;
    playSourceInfo: SourceEntity[];
    status: string;
    language: string;
}

export interface SourceEntity {
    sourceName: string;
    sourceUrl: string;
}

export interface TvSeriesInfoPageRequest {
    pageCurrent: number;
    pageSize: number;
    famousPersonId: number;
    keyword?: string;
    status?: string;
    type?: string;
}


// 新增
export async function addTvSeriesInfo(data: Omit<TvSeriesInfo, 'id'>) {
    return request('/tv-series-info/back', {
        method: 'POST',
        data,
    });
}

// 更新
export async function updateTvSeriesInfo(data: TvSeriesInfo) {
    return request('/tv-series-info/back', {
        method: 'PUT',
        data,
    });
}

// 删除
export async function deleteTvSeriesInfo(idList: number[]) {
    const ids = idList.join(',');
    return request(`/tv-series-info/back/${ids}`, {
        method: 'DELETE',
    });
}

// 分页查询
export async function getTvSeriesInfoPage(params: TvSeriesInfoPageRequest) {
    return request<PageResponse<TvSeriesInfo>>('/tv-series-info/page', {
        method: 'POST',
        data: params,
    });
}

// 根据id获取影视详情
export async function getTvSeriesInfo(id: number) {
    return request<TvSeriesInfo>(`/tv-series-info/${id}`, {
        method: 'GET',
    });
}

// 添加状态枚举
export const TV_SERIES_STATUS = {
    ALL: { label: '全部', value: '' },
    WAITING_PLAY: { label: '待播', value: 'WAITING_PLAY' },
    PLAYING: { label: '在播', value: 'PLAYING' },
    FINISHED: { label: '已完结', value: 'FINISHED' },
    UNKNOWN: { label: '未知', value: 'UNKNOWN' },
};


export const TV_SERIES_TYPE = {
    ALL: { label: '全部', value: '' },
    SERIES: { label: '剧集', value: 'SERIES' },
    MOVIE: { label: '电影', value: 'MOVIE' },
    UNKNOWN: { label: '未知', value: 'UNKNOWN' },
};

